//
//  YQTransferVC.m
//  NewRetail
//
//  Created by yuqin on 2019/6/23.
//  Copyright © 2019年 yuqin. All rights reserved.
//

#import "YQTransferVC.h"
#import "YQTransferCell.h"
#import "YQTransferHeadView.h"
#import "YQTransferFootView.h"
#import "YQTransferDetailVC.h"
#import "YQCollectionVC.h"

@interface YQTransferVC ()<UITableViewDelegate,UITableViewDataSource,DZNEmptyDataSetSource,DZNEmptyDataSetDelegate>

@property (nonatomic, strong) UITableView *transferTableView;
@property (nonatomic, strong) YQTransferHeadView *transferHeadView;
@property (nonatomic, strong) YQTransferFootView *footView;

@end

@implementation YQTransferVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.txtTitle.text = @"WDC资产";
    [self setupTransferView];
}

- (void)setupTransferView {
    
    [self.view addSubview:self.transferHeadView];
    [self.transferHeadView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.mas_equalTo(NavigationStatusBarHeight);
        make.size.mas_equalTo(CGSizeMake(ScreenWidth, FIT(64)));
    }];
    
    UILabel *theTitleLab = [YQViewFactory labelWithTextColor:UIColorFromRGB(0xbdbdc7) textAlignment:NSTextAlignmentLeft fontSize:kDescribeFont userBold:NO];
    theTitleLab.text = @"最近交易记录";
    [self.view addSubview:theTitleLab];
    [theTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(FIT(16));
        make.top.equalTo(self.transferHeadView.mas_bottom).mas_equalTo(0);
        make.size.mas_equalTo(CGSizeMake(ScreenWidth-FIT(32), FIT(60)));
    }];
    
    [self.view addSubview:self.transferTableView];
    [self.transferTableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.equalTo(theTitleLab.mas_bottom).mas_equalTo(0);
        make.size.mas_equalTo(CGSizeMake(ScreenWidth, ScreenHeight-NavigationStatusBarHeight-FIT(184)));
    }];
    
    [self.view addSubview:self.footView];
    
}

- (UITableView *)transferTableView {
    if (!_transferTableView) {
        _transferTableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
        _transferTableView.delegate = self;
        _transferTableView.dataSource = self;
        YQ_TableView_Empty(_transferTableView);
        _transferTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        [_transferTableView registerNib:[UINib nibWithNibName:YQ_TransferCell bundle:nil] forCellReuseIdentifier:YQ_TransferCell];
    }
    return _transferTableView;
}

- (YQTransferHeadView *)transferHeadView {
    if (!_transferHeadView) {
        _transferHeadView = [[YQTransferHeadView alloc] init];
    }
    return _transferHeadView;
}

- (YQTransferFootView *)footView {
    if (!_footView) {
        _footView = [[YQTransferFootView alloc] initWithFrame:CGRectMake(0, ScreenHeight-Botoom_IPhoneX-FIT(60), ScreenWidth, FIT(50))];
        _footView.backgroundColor = WhiteColor;
        @weakify(self);
        _footView.SelectBlock = ^(NSInteger index) {
            @strongify(self);
            if (index == 1) {
                YQ_PUSH([YQCollectionVC new]);
               
            }else {
                YQ_PUSH([YQTransferDetailVC new]);
            }
        };
    }
    return _footView;
}

#pragma mark - delegate/DataSource

YQ_ImageForEmptyDataSet(@"暂无交易记录", @"");

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 2;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return transferCellHeight;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    YQTransferCell *cell = [tableView dequeueReusableCellWithIdentifier:YQ_TransferCell forIndexPath:indexPath];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
}



@end
